<?php
namespace Home\Controller;

use Think\Controller;

class IndexController extends Controller
{

    public function index()
    {
        $province = M('Region')->where(array('region_type'=>1))->field('region_id,region_name')->order('sort_order desc')->select();

        $this->assign('province',$province);

        $this->display();
    }

    /**
     * 获取城市
     */
    public function getCity(){

        $where['region_type'] = 2;
        $where['parent_id'] = I('post.region_id');
        $city = M('Region')->where($where)->field('region_id,region_name')->order('sort_order desc')->select();


        $this->ajaxReturn($city,Json);
    }

    /**
     * 获取地区
     */
    public function getArea(){
        $where['region_type'] = 3;
        $where['parent_id'] = I('post.region_id');
        $area = M('Region')->where($where)->field('region_id,region_name')->order('sort_order desc')->select();
        $this->ajaxReturn($area,Json);
    }
}